<template>
    <div>
        <form action="#">
            name=><input type="text" v-model="link.name">{{link.name}}<br>
            url=><input type="text" v-model="link.url">{{link.url}}<br>
            id=><input type="text" v-model="link.id">{{link.id}}<br>
            <input type="hidden" v-model="link.do_submit">{{link.do_submit}}<br>

            <button @click.prevent="dosubmit">+++</button>
        </form>
    </div>
</template>

<script>
    // import axios from 'axios';
    import {post} from '../../network/request'

    export default {
        name: "MyConn",
        props: {
            article: {type: Array}
        },
        data() {
            return {
                mess: 'this is main test',
                num: 0,
                link: {
                    name: '',
                    url: '',
                    id: 0,
                    do_submit: true,
                }
            }
        },
        beforeUnmount() {
            console.log('unmount conn');
        },
        unmounted() {
            console.log('unmounted conn');
        },
        activated() {
            console.log('unmount conn with keep-alive');
        },
        deactivated() {
            console.log('unmounted conn with keep-alive');
        },
        methods: {
            changeCount(num) {
                this.$emit('mycountevent', num)
            },
            toparent() {
                this.$parent.change();
                this.$root.appmet();
            },
            changeNum() {
                this.num++;
            },
            dosubmit() {
                /*
                                axios.post('http://127.0.0.1:9000/postT', this.link, {
                                    transformRequest: {
                                        function(data) {
                                            let str = '';
                                            for (let key in data) {
                                                str += encodeURIComponent(key) + '='
                                                    + encodeURIComponent(data[key]) + '&';
                                            }
                                            return str;
                                        }
                                    },
                                    headers: {
                                        "Content-Type": "application/x-www-form-urlencoded"
                                    }
                                }).then(res => {
                                    console.log(res.data);
                                }).catch(err => console);
                */
                post('postT', this.link).then(res => {
                    console.log(res.data);
                }).catch(err => console);
            }
        },
    }
</script>

<style scoped>
    .myconn {
        width: 60%;
        height: 40%;
        background: aqua;
        margin: 10px;
    }
</style>